@extends('blog.layouts.app')

@section('title', $article->title)
@section('keyword', $article->keywords)
@section('description', $article->description)

@section('content')
    @if($article->password && request()->isMethod('GET'))
        {{-- 有密码加密文章 --}}
    <div class="article-body text-center">
        @if ($errors->any())
            <div style="color: #a94442;">{{ $errors->first() }}</div>
        @endif
        <form class="form-inline" method="POST">
            <div class="form-group {!! $errors->any() ? 'has-error' : '' !!}">
                <label class="sr-only" for="article-password">Please input password</label>
                <div class="input-group">
                    @csrf
                    <div class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></div>
                    <input type="password" class="form-control" id="article-password"
                           placeholder="请输入查看密码" name="article_password" autocomplete="new-password" autofocus required>
                </div>
            </div>
            <button type="submit" class="btn btn-primary">确定</button>
        </form>
        <i class="glyphicon glyphicon-lock" style="font-size: 200px; margin-top: 30px;"></i>
    </div>
    @else
    <div class="article-body">
        <div class="article-show">
            <h1 class="text-center">{{ $article->title }}</h1>
            <div class="text-center">
                <ul class="meta">
                    <li><i class="glyphicon glyphicon-user"></i> {{ $article->author }}</li>
                    <li><i class="glyphicon glyphicon-time"></i> {{ $article->created_at }}</li>
                    <li><i class="glyphicon glyphicon-eye-open"></i> {{ $article->view_count }}</li>
                    @if($article->copyfrom)
                        <li>转载：<a target="_blank" class="text-muted" href="{{ $article->copyfrom }}">来源</a></li>
                    @endif
                    {{--<li><i class="glyphicon glyphicon-comment"></i><span class="hits"> 0</span>条</li>--}}
                </ul>
            </div>
            <div class="clearfix"></div>
            @if(!empty($article->description))
                <blockquote class="blockquote">{{ $article->description }}</blockquote>
            @endif
            {{--<p class="contents">{!! $article->content !!}</p>--}}
            <p class="contents">{!! Parsedown::instance()->text($article->content) !!}</p>
            <div class="readme text-center">{{ $article->copyright }}</div>
        </div>
        <div class="article-footer">
            <div class="tags pull-left">

                <span class="label"></span>
            </div>
            <div class="share pull-right">
                <div class="bdsharebuttonbox">
                    <a href="#" class="bds_youdao" data-cmd="youdao" title="分享到有道云笔记"></a>
                    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
                    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
                    <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博">
                    </a><a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
                    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
        <nav>
            <ul class="pager">
                <li class="previous">
                    @if(isset($next->title))
                        <a class="pre_a" href="{{ route('article.show', [$next->id]) }}">{{ $next->title }}</a>
                    @else
                        已经没有了
                    @endif
                </li>
                <li class="next">
                    @if(isset($previous->title))
                        <a class="pre_a" href="{{ route('article.show', [$previous->id]) }}">{{ $previous->title }}</a>
                    @else
                        已经没有了
                    @endif
                </li>
            </ul>
        </nav>
    </div>
    @endif
@stop
@section('script')
    <script src="{{ asset('vendor/highlight/highlight.pack.js') }}"></script>
    <script>
        hljs.initHighlightingOnLoad();
        window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
    </script>
@stop
